package com.xiaochen.equals_;

public class EqualsExercise01 {
    public static void main(String[] args) {
        Person jack = new Person("jack", 18, '男');
        Person tom = new Person("tom", 18, '男');
        System.out.println(jack.equals(tom));

        Object obj = new Object();
        System.out.println(obj);
    }
}

class Person {
    private String name;
    private int age;
    private char gender;


    public Person(String name, int age, char gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof Person) {
            Person p = (Person) obj;
            return this.name == p.name && this.age == p.age && this.gender == p.gender;
        }
        return false;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }
}